package cn.edu.nju.oraldefense.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import cn.edu.nju.oraldefense.dao.TeacherDao;
import cn.edu.nju.oraldefense.model.Teacher;
import cn.edu.nju.oraldefense.service.TeacherService;

@Component("teacherService")
public class TeacherServiceImpl implements TeacherService {
	private TeacherDao teacherDao;

	public TeacherDao getTeacherDao() {
		return teacherDao;
	}

	@Resource
	public void setTeacherDao(TeacherDao teacherDao) {
		this.teacherDao = teacherDao;
	}

	public Teacher getById(int id) {
		return teacherDao.findById(id);
	}

	public Teacher getByNumber(String number) {
		List list = teacherDao.findByNumber(number);
		Teacher teacher = null;
		if (list != null && list.size() > 0)
			teacher = (Teacher) list.get(0);
		return teacher;
	}

	public List getAll() {
		return teacherDao.findAll();
	}

	public int getCount() {
		return teacherDao.findCount();
	}

	public List getByPage(int start, int limit) {
		return teacherDao.findByPage(start, limit);
	}

	public void addTeacher(Teacher t) {
		teacherDao.save(t);
	}

	public void removeTeacher(Teacher t) {
		teacherDao.delete(t);
	}

	public void modifyTeacher(Teacher t) {
		teacherDao.update(t);
	}

}
